package org.jmr.lang.a;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import org.eclipse.jface.preference.IPreferenceStore;
import org.jmr.lang.Activator;

public class b {

	private static List<a> listeners = new ArrayList<a>();
	private static IPreferenceStore store;
	
	public static void a(a listener){
		store = Activator.getDefault().getPreferenceStore();
		listeners.add(listener);
	}

	public static List<a> b(){
		return listeners;
	}

	public static void c(int b){
		store.setValue(a.LANGUAGE, b);
		for (int i = 0; i < listeners.size(); i++) {
			a listener = listeners.get(i);
			listener.changeLanguage(b);
		}
	}

	public static int d(){
		IPreferenceStore store = Activator.getDefault().getPreferenceStore();
		int language = store.getInt(a.LANGUAGE);
		if(a.CHINESE == language){
			return a.CHINESE;
		}else if(a.ENGLISH == language){
			return a.ENGLISH;
		}else{
			if(Locale.CHINESE.getLanguage() == Locale.getDefault().getLanguage()){
				return a.CHINESE;
			}else{
				return a.ENGLISH;
			}
		}
	}

}
